import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://nuxt.com/docs/api/configuration/nuxt-config
// @ts-ignore
export default defineNuxtConfig({
  ssr: false,
  telemetry: false,
  runtimeConfig: {
    public: {
      apiBase: '',
      requestSalt: 'nuxt3-visitor-0410'
    }
  },

  typescript: {
    shim: false
  },

  modules: [
    '@element-plus/nuxt',
    '@pinia/nuxt',
    '@pinia-plugin-persistedstate/nuxt'
  ],

  css: [
    'normalize.css',
    'element-plus/dist/index.css',
    'element-plus/theme-chalk/display.css',
    '@/assets/css/main.css'
  ],

  vite: {
    css: {
      preprocessorOptions: {
        scss: {
          api: 'modern-compiler',
          silenceDeprecations: ['legacy-js-api'],
          additionalData: '@use "@/assets/index.scss" as *;'
        }
      }
    },
    plugins: [
      AutoImport({
        resolvers: [ElementPlusResolver()]
      }),
      Components({
        resolvers: [ElementPlusResolver()]
      })
    ]
  },

  // https://nuxt.com.cn/modules/element-plus#themes
  elementPlus: {
    icon: 'ElIcon',
    importStyle: 'scss',
    themes: ['dark']
  },

  app: {
    head: {
      title: '数字统计',
      htmlAttrs: {
        lang: 'en'
      },
      viewport: 'width=device-width,initial-scale=1,user-scalable=no',
      meta: [
        {
          'http-equiv': 'Expires',
          content: '0'
        },
        {
          'http-equiv': 'Pragma',
          content: 'no-cache'
        },
        {
          'http-equiv': 'Cache',
          content: 'no-cache'
        },
        {
          'http-equiv': 'Cache-Control',
          content: 'no-cache, no-store, must-revalidate'
        },
        {
          charset: 'utf-8'
        },
        { hid: 'keywords', name: 'keywords', content: '数字统计, keywords' }
      ],
      link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
      script: [
        {
          src: 'https://gg-common.oss-cn-beijing.aliyuncs.com/js/moyutime.js?v=2'
        }
      ]
    }
  },

  devServer: {
    port: 3007
  },
  compatibilityDate: '2024-12-02'
})